/*
 * Copyright 2008-2010 GP Software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/**
 * DataSetUtil.java | Created on Sep 29, 2010
 */
package org.gpsoftware.xlsMerge;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.File;
import java.util.Set;
import java.util.TreeSet;

/**
 * Data set utility class
 *
 * @author Paul Augustine C. Mendoza
 */
public final class DataSetUtil {

    private DataSetUtil() {
        // Do nothing...
    }

    public static File getGoodTestFile(File basePath) {
        return new File(basePath, "test.xls");
    }

    public static File getInvalidTestFile(File basePath) {
        return new File(basePath, "invalid file.txt");
    }

    public static File getMissingTestFile(File basePath) {
        return new File(basePath.getName() + " does not exist");
    }

    public static Set<Row<HSSFRow>> getTestRows() {
        HSSFWorkbook workbook = new HSSFWorkbook();
        Set<Row<HSSFRow>> rows = new TreeSet<Row<HSSFRow>>();
        HSSFSheet sheet = workbook.createSheet();

        HSSFRow row0 = sheet.createRow((short) 0);
        row0.createCell(0).setCellValue("");
        row0.createCell(1).setCellValue("en");
        row0.createCell(2).setCellValue("pt");
        rows.add(new XlsRow(row0));

        HSSFRow row1 = sheet.createRow((short) 1);
        row1.createCell(0).setCellValue("about");
        row1.createCell(1).setCellValue("About");
        row1.createCell(2).setCellValue("Sobre");
        rows.add(new XlsRow(row1));

        HSSFRow row2 = sheet.createRow((short) 2);
        row2.createCell(0).setCellValue("phone");
        row2.createCell(1).setCellValue("Phone");
        row2.createCell(2).setCellValue("Fone");
        rows.add(new XlsRow(row2));

        return rows;
    }
}
